Install tests
authorColin Walters <walters@verbum.org>
Wed, 1 May 2013 19:26:21 +0000 (15:26 -0400)
committerColin Walters <walters@verbum.org>
Wed, 1 May 2013 19:26:21 +0000 (15:26 -0400)
Matching https://live.gnome.org/GnomeGoals/InstalledTests

12 files changed:
Makefile-tests.am [new file with mode: 0644]
Makefile.am
configure.ac
tests/libtest.sh
tests/t0000-basic.sh
tests/t0001-archive.sh
tests/t0002-archivez.sh
tests/t0003-log.sh
tests/t0004-remote-add.sh
tests/t0005-corruption.sh
tests/t0006-libarchive.sh
tests/t0011-pull-archive-z.sh

diff --git a/Makefile-tests.am b/Makefile-tests.am
new file mode 100644 (file)
index 0000000..cd22ab2
--- /dev/null
@@ -0,0 +1,49 @@
+# Makefile for tests code
+#
+# Copyright (C) 2013 Colin Walters <walters@verbum.org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+
+if BUILDOPT_INSTALL_TESTS
+insttestdir=$(pkglibexecdir)/installed-tests
+testfiles = t0000-basic \
+       t0001-archive \
+       t0002-archivez \
+       t0003-log \
+       t0004-remote-add \
+       t0005-corruption \
+       t0006-libarchive \
+       t0011-pull-archive-z \
+       $(NULL)
+insttest_SCRIPTS = $(addprefix tests/,$(testfiles:=.sh))
+
+insttest_DATA = tests/archive-test.sh \
+       tests/pull-test.sh \
+       tests/libtest.sh \
+       $(NULL)
+
+%.test: tests/%.sh Makefile
+       $(AM_V_GEN) (echo '[Test]' > $@.tmp; \
+        echo 'Exec=$(pkglibexecdir)/installed-tests/$(notdir $<)' >> $@.tmp; \
+        echo 'Type=session' >> $@.tmp; \
+        echo 'Output=TAP' >> $@.tmp; \
+        mv $@.tmp $@)
+
+testmetadir = $(datadir)/installed-tests/$(PACKAGE)
+testmeta_DATA = $(testfiles:=.test)
+
+endif
index e73c988b263a09cc8654e0056390736ce2d6bb9a..e3ce06cfd71b0f795c7e9626713d1b95ceb23afb 100644 (file)
@@ -84,6 +84,8 @@ include Makefile-libostree.am
 include Makefile-ostree.am
 include Makefile-switchroot.am
 include Makefile-triggers.am
+include Makefile-tests.am
+
 
 #  Docbook generation copied from systemd/Makefile.am
 #
index a81deadc40bf4e10003840dde497eef26295a03e..d95f5d8e4f8622153e535cafb867dac14e04a598 100644 (file)
@@ -33,6 +33,12 @@ AC_ARG_ENABLE(triggers-only,
            enable_triggers_only=no)
 AM_CONDITIONAL(TRIGGERS_ONLY, test x$enable_triggers_only != xno)
 
+AC_ARG_ENABLE(installed_tests,
+              AS_HELP_STRING([--enable-installed-tests],
+                             [Install test programs (default: no)]),,
+              [enable_installed_tests=no])
+AM_CONDITIONAL(BUILDOPT_INSTALL_TESTS, test x$enable_installed_tests = xyes)
+
 AC_CHECK_HEADER([attr/xattr.h],,[AC_MSG_ERROR([You must have attr/xattr.h from libattr])])
 
 PKG_PROG_PKG_CONFIG
index 93f8a7d4d2a13ce1274e0ba89c61b3360ff43e8c..e4518f1f10b95c13d9696240ca4e02dea99b5f3b 100644 (file)
 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-cd `dirname $0`
-SRCDIR=`pwd`
-cd -
-TMPDIR=${TMPDIR:-/tmp}
-export TMPDIR
-test_tmpdir=`mktemp -d "$TMPDIR/ostree-tests.XXXXXXXXXX"`
-cd "$test_tmpdir"
-touch "$test_tmpdir/.test$$"
+SRCDIR=$(dirname $0)
+test_tmpdir=$(pwd)
 
 export G_DEBUG=fatal-warnings
 
@@ -36,14 +30,6 @@ if test -n "$OT_TESTS_VALGRIND"; then
     CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${SRCDIR}/ostree-valgrind.supp"
 fi
 
-die () {
-    if test -z "$OT_TESTS_DEBUG"; then
-        test -f "$test_tmpdir/.test$$" && rm -rf "$test_tmpdir"
-    else
-        echo "Temporary files saved in $test_tmpdir"
-    fi
-}
-
 assert_streq () {
     test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
 }
@@ -110,6 +96,9 @@ setup_test_repository () {
 }
 
 setup_fake_remote_repo1() {
+    if ! test -x ${SRCDIR}/run-apache; then
+       exit 77
+    fi
     mode=$1
     shift
     oldpwd=`pwd`
@@ -170,5 +159,3 @@ EOF
 
     export OSTREE="ostree --repo=repo"
 }
-
-trap 'die' EXIT
index 60c20a6730331633b6952776c76715c18b406998..a55c748cd0a7d0f35d627814738f391f73498d44 100755 (executable)
@@ -21,7 +21,7 @@ set -e
 
 echo "1..30"
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 setup_test_repository "bare"
 echo "ok setup"
@@ -218,4 +218,3 @@ echo "ok subdir enoent"
 cd ${test_tmpdir}
 $OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null
 echo "ok subdir noent"
-
index 642cdf9ed17c1c148a3ab04005fc96539651b2c6..c9f934c4d0883fb98002d42b4922c9b48b87f022 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -e
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 echo '1..11'
 
index 084481627a9e1601014ee9b202363b8e78b3411c..b9f41919915895f27e38a21177387ca95458671a 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -e
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 echo '1..11'
 
index 2fb5ea804279603ba5a23391ed4cce46d25f5804..7c415ff8d4e87de9779395d2fc5361c1d77ee07e 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -e
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 echo "1..1"
 
index ffab0fa9a57686a02d3ab2e4461a42b08c304dd5..252090b3dc1d72767ed2921aed34ba1fc70f16a2 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -e
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 echo '1..2'
 
index 3961d46b87ebcdaadd469c5700d4f7500d9bbffb..258e0bdc4b14e658eeb22c263402c3cb4587a057 100755 (executable)
@@ -21,7 +21,7 @@ set -e
 
 echo "1..1"
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 setup_test_repository "bare"
 $OSTREE checkout test2 checkout-test2
index d941f472078f4c58a0a5b9875267537963b4b83c..4936389cee373150244ee7d51df28bd69fd61216 100755 (executable)
@@ -21,7 +21,7 @@ set -e
 
 echo "1..7"
 
-. libtest.sh
+. $(dirname $0)/libtest.sh
 
 setup_test_repository "bare"
 cd ${test_tmpdir}
index c06003fa26b6d9e605e612f3478d4b78fd53d6f2..0d2085285c71817e77ef40c68797c393aaae7f33 100755 (executable)
 
 set -e
 
-. libtest.sh
-
-echo '1..2'
+. $(dirname $0)/libtest.sh
 
 setup_fake_remote_repo1 "archive-z2"
 
+echo '1..2'
+
 . ${SRCDIR}/pull-test.sh